# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=unibilium
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.1.2
pkgrel=1
pkgdesc="A terminfo parsing library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/neovim/unibilium'
license=('spdx:LGPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/neovim/unibilium/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "0002-unibilium-make-add-no-undefined.patch")
sha256sums=('370ecb07fbbc20d91d1b350c55f1c806b06bf86797e164081ccc977fc9b3af7a'
            '8980bea1618fca569939738f4433b98dfc9b33b3a67e71898b800fa43a93a274')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0002-unibilium-make-add-no-undefined.patch"
  autoreconf -fiv
}

build() {
  cp -r "${_realname}-${pkgver}" "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  ./configure \
    --prefix="${MINGW_PREFIX}" \
    --enable-static \
    --enable-shared

  make -j1
}

check() {
  cd "build-${MSYSTEM}"
  make test
}

package() {
  cd "build-${MSYSTEM}"
  make install PREFIX=${MINGW_PREFIX} DESTDIR="${pkgdir}"
}
